home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu291.dms / pu291.adf / Clocks / nums2c.rexx < prev    next >
OS/2 REXX Batch file  |  1992-08-03  |  1KB  |  63 lines

  1. /* convert .* number pictures to C declarations */
  2.  
  3. count = 0
  4. char. = ""
  5. plane0. = 0
  6. plane1. = 0
  7.  
  8. l = readln(stdin)
  9. do while ~eof(stdin)
  10.   count = count + 1
  11.   parse var l e char
  12.   char.count = strip(char)
  13.   if e ~= '=' then do
  14.       say 'ERROR, expecting = as first character at:'
  15.     say l
  16.     exit 10
  17.   end
  18.   do i = 1 to 10
  19.     l = readln(stdin)
  20.     if eof(stdin) then do
  21.       say 'unexpected EOF found'
  22.       exit 10
  23.     end
  24.       call makeplanes(count,l,i)
  25.   end
  26.  
  27.   l = readln(stdin)
  28. end
  29.  
  30. call writeln(stdout,"static UBYTE nums["count"][2][10] = {");
  31. do j = 1 to count
  32.   call writech(stdout,"    { {"plane0.j.1);
  33.   do i = 2 to 10
  34.     call writech(stdout,","plane0.j.i);
  35.   end
  36.   call writeln(stdout,"},");
  37.  
  38.   call writech(stdout,"      {"plane1.j.1);
  39.   do i = 2 to 10
  40.     call writech(stdout,","plane1.j.i);
  41.   end
  42.   call writeln(stdout,"} }, /*" char.j "*/")
  43. end
  44. call writeln(stdout,"};");
  45.  
  46. exit
  47.  
  48. makeplanes: procedure expose plane0. plane1.
  49.     parse arg count,v,n
  50.     v = strip(v)
  51.     plane0 = 0
  52.     plane1 = 0
  53.     do i = 0 to length(v)-1
  54.         d = substr(v,i+1,1)
  55.         plane0 = plane0 * 2
  56.         plane1 = plane1 * 2
  57.         if (d = 1 | d = 3) then plane0 = plane0 + 1
  58.         if (d = 2 | d = 3) then plane1 = plane1 + 1
  59.     end
  60.     plane0.count.n = "0x"c2x(d2c(plane0))
  61.     plane1.count.n = "0x"c2x(d2c(plane1))
  62.     return
  63.